import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

public class player {
	private String name;
	private Set<String>guessedWords;
	private List<String>acceptedWords;

	//Instantiates new player
	public player(String name){
		this.name = name;
		guessedWords = new LinkedHashSet<String>();
		acceptedWords = new ArrayList<String>();
	}

//	//Instantiates player with guessed word list
//	public player(String name, List<String> guessedWords){
//		this(name);
//		this.guessedWords = guessedWords;
//	}

	//Returns name of player
	public String getName(){
		return name;
	}

	//Gets list of guessed words
	public Set<String> getGuessedWords(){
		return guessedWords;
	}

	//Returns true if word was already guessed
	public Boolean wordGuessed(String guessedWord){
		for(String guess : getGuessedWords()){
			if(guessedWord.toUpperCase().equals(guess.toUpperCase())){
				return true;
			}
		}
		return false;
	}

	//Adds guessed word
	public void addGuessedWord(String guessedWord){
		if(guessedWord.trim().length() >= 3)
			guessedWords.add(guessedWord.toUpperCase());
	}

	//Set accepted words
	public void setAcceptedWords(List<String> acceptedWords){
		this.acceptedWords = acceptedWords;
		Collections.sort(this.acceptedWords);
	}

	//Get accepted words
	public List<String> getAcceptedWords(){
		return this.acceptedWords;
	}

	//Returns stats
	public int[][] getStats(){
		//[0][0] = 3 - 4 words
		//[0][1] = 5 letters
		//[0][2] = 6 letters
		//[0][3] = 7 letters
		//[0][4] = 8 letters
		//[0][5] = 9+ letters
		//[0][6] = Total words
		
		//[1][0] = 3 - 4 words points (1)
		//[1][1] = 5 letters points (2)
		//[1][2] = 6 letters points (3)
		//[1][3] = 7 letters points (5)
		//[1][4] = 8 letters points (11)
		//[1][5] = 9+ letters points (2/letter)
		//[1][6] = Total Score
		
		int[][] stats = new int[2][7];
		for(int i = 0; i<7 ; i++) {
			stats[0][i] = 0;
			stats [1][i] = 0;
		}

		for(String word : getAcceptedWords()){
			switch (word.length()){
			case 3: stats[0][0]++; stats[1][0] += 1; stats[1][6] += 1; break;
			case 4: stats[0][0]++; stats[1][0] += 1; stats[1][6] += 1; break;
			case 5: stats[0][1]++; stats[1][1] += 2; stats[1][6] += 2; break;
			case 6: stats[0][2]++; stats[1][2] += 3; stats[1][6] += 3; break;
			case 7: stats[0][3]++; stats[1][3] += 5; stats[1][6] += 5; break;
			case 8: stats[0][4]++; stats[1][4] += 11; stats[1][6] += 11; break;
			default: stats[0][5]++;stats[1][5] += (word.length() * 2); stats[1][6] += (word.length() * 2); break;
			}
			//Total Words
			stats[0][6]++;
		}
		
		return stats;
	}
}
